package Frame;
/**
 * Interface : GestionCompte
 */

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.LayoutManager;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.SpringLayout;
import javax.swing.JLabel;

import java.awt.CardLayout;

import javax.swing.JPasswordField;
import javax.swing.JList;
import javax.swing.border.LineBorder;

import java.awt.Color;

import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.text.Normalizer.Form;
import java.util.ArrayList;
import java.util.Collection;

import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.AbstractListModel;

import Classe.Restaurant;
import Classe.Restaurateur;

import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;

import java.awt.Font;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;

import javax.swing.SwingConstants;

import Gestion.Service.GestionnaireClient;
import Gestion.Service.GestionnaireConnexion;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.DefaultComboBoxModel;
import javax.swing.UIManager;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Main_Visiteur extends JFrame {

	private JPanel contentPane;
	private JTextField txtIdentifiant;
	private JPasswordField pwdMDPRestaurateur;
	private JPasswordField pwdMDPConfirmation;
	private JTextField textField;
	GestionnaireConnexion gestionnaireConnexion;
	static Main_Visiteur frame = new Main_Visiteur();;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				
				try {
					
					
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Main_Visiteur() 
	{
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowOpened(WindowEvent arg0) {
			gestionnaireConnexion =	GestionnaireConnexion.getInstance();
			//gestionnaireConnexion.startDBConnection();
			}
			@Override
			public void windowClosed(WindowEvent e) {
				//gestionnaireConnexion.stopDBConnection();
			}
		});
		//Set default propriety
		this.setTitle("Gestion Restaurant");
		this.setSize(new Dimension(900,820));
		this.setLocation(300, 90);
		SpringLayout springLayout = new SpringLayout();
		getContentPane().setLayout(springLayout);
		
		JLabel lbl_Titre = new JLabel("Bienvenue ch\u00E8re visiteur");
		springLayout.putConstraint(SpringLayout.NORTH, lbl_Titre, 78, SpringLayout.NORTH, getContentPane());
		springLayout.putConstraint(SpringLayout.WEST, lbl_Titre, 257, SpringLayout.WEST, getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, lbl_Titre, -185, SpringLayout.EAST, getContentPane());
		lbl_Titre.setFont(new Font("Tahoma", Font.BOLD, 22));
		getContentPane().add(lbl_Titre);

		JButton btnAnnuler = new JButton("Quitter");
		btnAnnuler.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			
			}
		});
		getContentPane().add(btnAnnuler);
		
		JButton btnCrerCompte = new JButton("Cr\u00E9er votre compte client");
		springLayout.putConstraint(SpringLayout.NORTH, btnCrerCompte, 199, SpringLayout.SOUTH, lbl_Titre);
		springLayout.putConstraint(SpringLayout.SOUTH, btnCrerCompte, -414, SpringLayout.SOUTH, getContentPane());
		springLayout.putConstraint(SpringLayout.NORTH, btnAnnuler, 0, SpringLayout.NORTH, btnCrerCompte);
		springLayout.putConstraint(SpringLayout.WEST, btnAnnuler, 95, SpringLayout.EAST, btnCrerCompte);
		springLayout.putConstraint(SpringLayout.SOUTH, btnAnnuler, 0, SpringLayout.SOUTH, btnCrerCompte);
		springLayout.putConstraint(SpringLayout.EAST, btnAnnuler, 234, SpringLayout.EAST, btnCrerCompte);
		springLayout.putConstraint(SpringLayout.WEST, btnCrerCompte, 222, SpringLayout.WEST, getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, btnCrerCompte, 379, SpringLayout.WEST, getContentPane());
		btnCrerCompte.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ouvrirCreerCompte();				
				
							
			}
		});
		getContentPane().add(btnCrerCompte);
		
	}
	public void ouvrirCreerCompte()
	{
		this.setVisible(false);
		Compte compte = new Compte();
		compte.setVisible(true);
	}

	
}
